package com.zr.eim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zr.common.annotation.Log;
import com.zr.common.core.controller.BaseController;
import com.zr.common.core.domain.AjaxResult;
import com.zr.common.enums.BusinessType;
import com.zr.eim.domain.EimHomeInformation;
import com.zr.eim.service.IEimHomeInformationService;
import com.zr.common.utils.poi.ExcelUtil;
import com.zr.common.core.page.TableDataInfo;

/**
 * 居家检测Controller
 * 
 * @author zhaojunqi
 * @date 2022-10-21
 */
@RestController
@RequestMapping("/eim/information")
public class EimHomeInformationController extends BaseController
{
    @Autowired
    private IEimHomeInformationService eimHomeInformationService;

    /**
     * 查询居家检测列表
     */
    @PreAuthorize("@ss.hasPermi('eim:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(EimHomeInformation eimHomeInformation)
    {
        startPage();
        List<EimHomeInformation> list = eimHomeInformationService.selectEimHomeInformationList(eimHomeInformation);
        return getDataTable(list);
    }

    /**
     * 导出居家检测列表
     */
    @PreAuthorize("@ss.hasPermi('eim:information:export')")
    @Log(title = "居家检测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EimHomeInformation eimHomeInformation)
    {
        List<EimHomeInformation> list = eimHomeInformationService.selectEimHomeInformationList(eimHomeInformation);
        ExcelUtil<EimHomeInformation> util = new ExcelUtil<EimHomeInformation>(EimHomeInformation.class);
        util.exportExcel(response, list, "居家检测数据");
    }

    /**
     * 获取居家检测详细信息
     */
    @PreAuthorize("@ss.hasPermi('eim:information:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(eimHomeInformationService.selectEimHomeInformationById(id));
    }

    /**
     * 新增居家检测
     */
    @PreAuthorize("@ss.hasPermi('eim:information:add')")
    @Log(title = "居家检测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EimHomeInformation eimHomeInformation)
    {
        return toAjax(eimHomeInformationService.insertEimHomeInformation(eimHomeInformation));
    }

    /**
     * 修改居家检测
     */
    @PreAuthorize("@ss.hasPermi('eim:information:edit')")
    @Log(title = "居家检测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EimHomeInformation eimHomeInformation)
    {
        return toAjax(eimHomeInformationService.updateEimHomeInformation(eimHomeInformation));
    }

    /**
     * 删除居家检测
     */
    @PreAuthorize("@ss.hasPermi('eim:information:remove')")
    @Log(title = "居家检测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eimHomeInformationService.deleteEimHomeInformationByIds(ids));
    }
}
